/**游戏引擎总控制
 * @date   2011-5-1
 * @author tianye
 */
package cn.edu.dlut.WingGame.Game;

import cn.edu.dlut.WingGame.Graphic.GLDevice;
import cn.edu.dlut.WingGame.Object.WingObject;

public class WingGame {
	private static WingActivity mainActivity;// 当前程序句柄

	private static boolean showfpsFlag = false;// 是否显示FPS
	private static boolean renderfpsFlag = false;// 是否强制绘图频率

	public static void setActivity(WingActivity mainActivity) {
		WingGame.mainActivity = mainActivity;
	}

	public static WingActivity getActivity() {
		return mainActivity;
	}

	public static boolean initWingGame(WingActivity activity) {
		setActivity(activity);
		// 初始化图形系统
		GLDevice.setActivity(activity);
		GLDevice.setBKColor(200, 200, 200);
		return true;
	}

	public static void quitWingGame() {
		mainActivity.mLoop.stopLoop();
		mainActivity.finish();
	}

	public static void setFPS(int fps, boolean renderFPS) {
		mainActivity.mLoop.setFPS(fps);
		renderfpsFlag = renderFPS;
		if (renderfpsFlag) {
			mainActivity.mRender.setFPS(fps);
		}
	}

	public static void render() {
		mainActivity.mContainer.render();
	}

	public static void update() {
		mainActivity.mContainer.update();
	}

	public static void setShowFPS(boolean showfpsFlag) {
		WingGame.showfpsFlag = showfpsFlag;
	}

	public static boolean isShowFPS() {
		return showfpsFlag;
	}

	public static boolean isRenderFPS() {
		return renderfpsFlag;
	}

	// ------------------------------------------------------------------
	public static boolean addScene(WingObject scene) {
		return mainActivity.mContainer.addScene(scene);
	}

	public static WingObject getScene(int id) {

		return mainActivity.mContainer.getScene(id);
	}

	public static WingObject getScene(String name) {

		return mainActivity.mContainer.getScene(name);
	}

	public static void setCurrentScene(String scenename) {
		mainActivity.mContainer.setCurrentScene(scenename);
	}

	public static void setCurrentScene(int id) {
		mainActivity.mContainer.setCurrentScene(id);
	}

	public static WingObject getCurrentScene() {
		return mainActivity.mContainer.getCurrentScene();
	}
	// --------------------------------------------------------------------

}
